package com.example.twotwo_project;

import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class LoginActivity extends ActionBarActivity {
    
	Intent intent = null;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_login);
        getActionBar().setDisplayHomeAsUpEnabled(true);
        
	}
	
	public void btn_ok(View v){
		EditText mid = (EditText)findViewById(R.id.editText1);
		EditText pwd = (EditText)findViewById(R.id.editText2);
		
		if(mid.getText().toString().equals("")){
			Toast.makeText(getApplicationContext(), "아이디를 입력해 주세요", Toast.LENGTH_SHORT).show();
		}else{
			Toast.makeText(getApplicationContext(), "아이디 입력!", Toast.LENGTH_SHORT).show();
		}
		
		if(pwd.getText().toString().equals("")){
			Toast.makeText(getApplicationContext(), "패스워드를 입력해 주세요", Toast.LENGTH_SHORT).show();
		}else{
			Toast.makeText(getApplicationContext(), "패스워드 입력!", Toast.LENGTH_SHORT).show();
		}
		
	}
	
	public void btn_input(View v){
		intent = new Intent(getApplicationContext(), InputActivity.class);
		startActivity(intent);
	}
	
	public void btn_re_mid(View v){
		intent = new Intent(getApplicationContext(), Mid_ResearchActivity.class);
		startActivity(intent);
	}
	
	public void btn_re_pwd(View v){
		intent = new Intent(getApplicationContext(), Pwd_ResearchActivity.class);
		startActivity(intent);
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.login, menu);
		return true;
	}
	
	

	@Override
	public boolean onOptionsItemSelected(android.view.MenuItem item) {
		/*int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}*/
		switch(item.getItemId()){
		case android.R.id.home:
			intent = new Intent(getApplicationContext(), MainActivity.class);
			intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
			startActivity(intent);
			return true;
		}
		return super.onOptionsItemSelected(item);
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		switch(keyCode){
		case KeyEvent.KEYCODE_BACK:
			intent = new Intent(getApplicationContext(), MainActivity.class);
			intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
			startActivity(intent);
			break;
		}
		
		return super.onKeyDown(keyCode, event);
	}
	
	
}
